import matplotlib.pyplot as plt
import numpy as np
import statistics

n500 = []
n1000 = []
n3000 = []
n5000 = []
for line in open('out/n500.out'):
    n500.append(float(line))
# for line in open('lr10.out'):
#     n1000.append(float(line))
# for line in open('lr15.out'):
#     n3000.append(float(line))

print 'n: 500 ==>'
print 'avg: %f' % statistics.mean(n500)
print 'max: %f' % max(n500)
print 'min: %f' % min(n500)
print 'med: %f' % statistics.median(n500)
print 'percent95 under: %f' % sorted(n500)[int(len(n500)*0.95)]

# print 'lr: 10% ==>'
# print 'avg: %f' % statistics.mean(n1000)
# print 'max: %f' % max(n1000)
# print 'min: %f' % min(n1000)
# print 'med: %f' % statistics.median(n1000)
# print sorted(n1000)[284]
#
# print 'lr: 15% ==>'
# print 'avg: %f' % statistics.mean(n3000)
# print 'max: %f' % max(n3000)
# print 'min: %f' % min(n3000)
# print 'med: %f' % statistics.median(n3000)
# print sorted(n3000)[284]


# plt.figure()
fig, ax = plt.subplots(figsize=(6, 4))
# ax.step(Xs, n, label='LR: 0%')
ax.step(np.sort(n500), np.arange(1, len(n500) + 1) / np.float(len(n500)), label='#Switches: 500')
# ax.step(np.sort(n1000), n, label='LR: 10%')
# ax.step(np.sort(n3000), n, label='LR: 15%')

ax.grid(True)
ax.legend()
ax.set_xlabel('Time (s)')
# plt.savefig('%s.png' % "out-cdf")
plt.show()